#include"db.h"
confinfo GetDataInfo(void)
{
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf-8"));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE","getdatainfo");
    db.setDatabaseName("./database");
    db.open();
    QSqlQuery query = db.exec("select savepath,pointcount from configure");
    query.next();
    //qDebug()<<query.lastError ().text();
    QSqlRecord record = db.record("configure");
    confinfo info;
    int savepathfield = record.indexOf("savepath");
    int pointcountfield = record.indexOf("pointcount");
    info.savepath = query.value(savepathfield).toString();
    info.pointcount = query.value(pointcountfield).toInt();
    db.close();
    QSqlDatabase::removeDatabase("getdatainfo");
    return info;
}

void execsql(QString str)
{
   QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
   db.setDatabaseName("./database");
   db.open();
   QSqlQuery query = db.exec(str);
   //db.commit();
   qDebug()<<"execsql:"<<query.lastError().text();
   db.close();
   QSqlDatabase::removeDatabase("execsql");
}
